import {
  Route,
  Redirect
} from "react-router-dom";

function PrivateRoute({ children, ...rest }) {
  let auth = Math.random() + 0.5
  console.log('PrivateRoute');
  return (
    <Route
      {...rest}
      render={({ location }) =>
        auth>0.5 ? (
          children
        ) : (
          <Redirect
            to={{
              pathname: "/login",
              state: { from: location }
            }}
          />
        )
      }
    />
  );
}

export default PrivateRoute